from multiprocessing import Process

a = 100


# 进程变量是不共享的
def add():
    global a
    a += 1
    # 100
    print("加后的a值", a)


def sub():
    global a
    a -= 1
    # 99
    print("减后的a值", a)


if __name__ == '__main__':
    # 100
    print("主进程的a值", a)
    p1 = Process(target=add)
    p2 = Process(target=sub)
    p1.start()
    p2.start()
    p1.join()
    p2.join()
    # 100
    print("最后主进程的a值", a)
